<!doctype html>
<html lang="en">

	<head>
		<meta charset="UTF-8" />
		<title>魏远商城</title>
		<link rel="stylesheet" href="../../css/login/login.css" />
	</head>

	<body>
		<div class="wrap">
			<div class="header">
				<img class="imageLogo" src="../../image/logol.png" alt="" height="100%" />
				<span>欢迎登录</span>
			</div>

			<div class="content">
				<div class="login">

					<div class="login-title">
						<span>账户登录</span><span></span>
					</div>

					<div class="login-content">
						<div class="line"></div>
						<span class="tu1"></span><input maxlength="11" type="text" class="phone" placeholder="请输入手机号" />
						<div class="line line1">*手机号不能为空</div>

						<span class="tu2"></span><input type="password" class="password" placeholder="请输入密码" />
						<div class="line line2">*密码不能为空</div>
						<input type="button" class="login-btn" value="登录" />
						<p class="jianhca">*请检查您的账号或密码哦</p>
					</div>

					<div class="login-foter">
						<span class="forgetpa">忘记密码</span><span class="regin">立即注册></span>
					</div>
				</div>
			</div>

			<div class="fotter">广东魏远科技有限公司版权所有</div>

		</div>
		<script src="../../assets/jquery-3.1.1.min.js"></script>
		<script src="../../js/url.js"></script>
		<script>
			var hm = /^1[34578]\d{9}$/;
			$('.regin').on('click', function() {
				window.location.href = '../login/register.html';
			})

			$('.forgetpa').on('click', function() {
				window.location.href = '../login/forget_p_1.html';
			})

			$('.login-btn').on('click', function() {
				if($('.phone').val() == '') {
					$('.line1').css('visibility', 'visible');
				}else if(!hm.test($('.phone').val())){
					$('.line1').css('visibility', 'visible');
					$('.line1').text('*请输入正确手机号码');
				} else if($('.password').val() == '') {
					$('.line2').css('visibility', 'visible');
				} else {
					$('.line1').css('visibility', 'hidden');
					$('.line2').css('visibility', 'hidden');
					$.ajax({
						type: 'post',
						url: ur + '/mobilemember/frontmember/dologin',
						dataType: 'json',
						data: {
							"memberVO.loginName": $('.phone').val(),
							"memberVO.password": $('.password').val(),
						},
						success: function(data) {
							console.log(JSON.stringify(data) + '>>>>>')
							var panduan = data.result.meta.code;
							if(panduan == '200') {

								if(data.result.data.isAdmin == 1) {

									localStorage.wyshopisAdmin = data.result.data.isAdmin;
									//						
								} else if(data.result.data.isAdmin == 2) {
									localStorage.wyshoppriseId = data.result.data.enterpriseId;
									localStorage.wyshopisAdmin = data.result.data.isAdmin;
								}

								localStorage.wyshoptoken = data.result.data.token;
								console.log(localStorage.token + '可以用的token');
								window.location.href = '../home/home.html';

							} else if(panduan == '110') {

								return;
							} else if(panduan == '308') {
								$('.jianhca').css('visibility', 'visible');
								return;
							} else {

								return;

							}

						},
						error: function(e) {
							console.log(e + '登录错误')
						}
					});

				}
			});
		</script>
	</body>

</html>